# --------------------------------------------------------------------  补充： sort排序
aa = [2, 3, 6, 4, 11, 100, 44]

aa.sort()
print(aa)

# -------------------------------------------------------------------   最基础的 while 循环
i = 1
sum = 0
while i <= 100:
    sum += i
    i += 1
print(f"1到100的总和：{sum}")

# ------------------------------------   猜数：flag = True，用 flag 做循环条件，猜对了就结束（flag=False，不满足循环条件，直接结束）
import random
num = random.randint(1,100)
flag = True
count = 0
while flag:
    guess_num = int(input("请输入数字："))
    count += 1
    if guess_num == num:
        print("猜对了")
        flag = False
    else:
        if guess_num > num:
            print("输入的数大了")
        else:
            print("输入的数小了")
print(f"一共猜了{count}次")

# -------------------------------------------------------------------  表白
# 外层控制变量
i = 1
while i <=100:
    print(f"表白的第{i}天")
    # 内层控制变量
    j = 1
    while j <= 10:
        print(f"送给小美的第{j}枝玫瑰花")
        j += 1
    print("小美，我喜欢你")
    i += 1
print(f"坚持到第{i-1}天，表白成功")

for x in range(10):
    print("送玫瑰花")

# -------------------------------------------------------------------    \t：   对齐符号
print("hello", end = '')
print("world")

print("hello\tword")
print("it\theima")

# -------------------------------------------------------------------    九九乘法表
# i控制行，j控制列
i = 1
while i <= 9:
    j = 1
    while j <= i:
        print(f"{j} * {i} = {j * i}\t", end = '')
        j += 1
    i += 1
    print()

# --------------------------------------------------------------------   最基础的 for 循环
name = "itheima"
for x in name:
    print(x)

# ----------------
name = "itheima is a brand of itcast"
count = 0
for x in name:
    print(x)
    if x == 'a':
        count += 1
print(f"a一共有{count}个")

# -----------------------------------------------------------------     range(2,9,3)   生成2开始，8结束，3为步长的整数序列
for x in range(2,9,3):
    print(x)

# --------------------------------------   计算有多少偶数
num = int(input("请输入数字："))
count = 0
for x in range(0,num):
    if ( x % 2 ) == 0:
        count += 1
    else:
        count += 0
print(f"偶数有{count}个")

# ---------------------------------------  表白的简洁版代码  range
for i in range(1,101):
    print(f"今天是表白的第{i}天")
    for j in range(1,11):
        print(f"送给小美的第{j}朵玫瑰花")
    print("小美我喜欢你")
print(f"第{i}天，表白成功")

# ---------------------------------       九九乘法表的简洁版  range
for i in range(1,10):
    for j in range(1,i + 1):
        print(f"{j} * {i} = { j * i}\t", end = '')
    print()

# --------------------------------------------------------          continue          break
money = 10000
import random
for i in range(1,21):
    score = random.randint(1,10)
    if score < 5:
        print(f"员工{i},绩效{score}不足，不发工资，下一个")
        continue
    if money >= 1000:
        money -= 1000
        print(f"员工{i}，绩效{score}满足，发1000元,账户余额{money}")
    else:
        print(f"账户余额{money}不足，下个月再来")
        break